package dao;

import domain.Person;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.List;

/**
 * @program: springbootjpa-01
 * @description:
 * @author: Mr.Dai
 * @create: 2020-01-01 16:21
 **/
@Repository
public class PersonDaoImpl implements PersonDao {

    @PersistenceContext
    private EntityManager entityManager;

    @Override
    public List<Person> findPerson() {
        Query query = entityManager.createQuery("select p from Person p");
        List list = query.getResultList();
        return list;
    }
}
